#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
struct student {
	int num;
	char name[10];
	int score;
	char rank;
};

int main()
{
	int i, n, count = 0;
	double;
	struct student students[10];

	scanf("%d", &n);
	if (n <= 0) {
		return 0;
	}
	for (i = 0; i < n; i++) {
		scanf("%d %s %d", &students[i].num, &students[i].name, &students[i].score);
		if (students[i].score >= 85 && students[i].score <= 100) {
			students[i].rank = 'A';
		}
		else if (students[i].score >= 70 && students[i].score <= 84) {
			students[i].rank = 'B';
		}
		else if (students[i].score >= 60 && students[i].score <= 69) {
			students[i].rank = 'C';
		}
		else {
			students[i].rank = 'D';
			count++;
		}
	}
	printf("The count for failed (<60): %d\n", count);
	printf("The grades:\n");
	for (i = 0; i < n; i++) {
		printf("%05d %s %c\n", students[i].num, students[i].name, students[i].rank);
	}

	return 0;
}